// 网页logo
export function setDocLogo(logo) {
  if (!logo) return;
  let link = document.createElement('link');
  link.type = 'image/x-icon';
  link.rel = 'shortcut icon';
  link.href = logo;
  document.getElementsByTagName('head')[0].appendChild(link);
}

// 网页标题
export function setDocTitle(title) {
  if (!title) return;
  document.title = title;
}

// 更换主题
export function setSkin(defaultColor, secondColor) {
  if (window.less) {
    defaultColor &&
      document.documentElement.style.setProperty(
        `--primary-color`,
        defaultColor,
      );
    secondColor &&
      document.documentElement.style.setProperty(
        `--my-btn-hover-bg`,
        secondColor,
      );
    window.less
      .modifyVars(
        // 要更换的变量
        {
          '@primary-color': defaultColor,
          '@my-btn-hover-bg': secondColor,
        },
      )
      .then(() => {
        console.log('success');
      })
      .catch(error => {
        console.log(error);
      });
  }
}
